<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0,user-scalable=no,minimal-ui">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="../img/asset-favico.ico">
    <title>健康干预</title>
    <link rel="stylesheet" href="../css/page-health-intervention.css" />
</head>

<body data-spy="scroll" data-target="#myNavbar" data-offset="150">
    <div class="app">
        <!-- 页面头部 -->
        <div class="top-header">
            <span class="f-left"><i class="icon-back" onclick="c3()"></i>返回</span>
            <span class="center">千锋健康</span>
            <span class="f-right"><i class="icon-more"></i></span>
        </div>
        <!-- 页面内容 -->
        <div class="contentBox">
            <div class="tab-wrapper">
                <ul class="tab-menu">
                    <li class="active">膳食方案</li>
                    <li id="spo" onclick="c1()">运动方案</li>
                    <li id="pla" onclick="c2()">干预计划</li>
                </ul>
                <div class="tab-content">
                    <div class="item">
                        <div class="intro-img">
                            <img src="../img/widget-program01.png" width="100%" />
                        </div>
                        <div class="table-title">
                            <span>餐次</span>
                            <span>推荐食物</span>
                            <span>份量</span>
                            <span>摄入量</span>
                        </div>
                        <table class="table" border="0" cellspacing="0" cellpadding="0">
                            <tbody id="diet1">
<!--                                <tr>-->
<!--                                    <td>1</td>-->
<!--                                    <td>面包、牛奶</td>-->
<!--                                    <td>50g</td>-->
<!--                                    <td>20k</td>-->
<!--                                </tr>-->
<!--                                <tr>-->
<!--                                    <td>2</td>-->
<!--                                    <td>面包、牛奶</td>-->
<!--                                    <td>50g</td>-->
<!--                                    <td>20k</td>-->
<!--                                </tr>-->
<!--                                <tr>-->
<!--                                    <td>3</td>-->
<!--                                    <td>面包、牛奶</td>-->
<!--                                    <td>50g</td>-->
<!--                                    <td>20k</td>-->
<!--                                </tr>-->
<!--                                <tr>-->
<!--                                    <td>4</td>-->
<!--                                    <td>面包、牛奶</td>-->
<!--                                    <td>50g</td>-->
<!--                                    <td>20k</td>-->
<!--                                </tr>-->
                            </tbody>
                        </table>

                    </div>
                    <div class="item">
                        <div class="table-title">
                            <span>运动名称</span>
                            <span>运动时长</span>
                            <span>运动周期</span>
                            <span>消耗量</span>
                        </div>
                        <table class="table" border="0" cellspacing="0" cellpadding="0">
                            <tbody id="sport">
<!--                                <tr>-->
<!--                                    <td>跑步</td>-->
<!--                                    <td>30min</td>-->
<!--                                    <td>每天</td>-->
<!--                                    <td>20kal</td>-->
<!--                                </tr>-->
<!--                                <tr>-->
<!--                                    <td>仰卧起坐</td>-->
<!--                                    <td>15min</td>-->
<!--                                    <td>每两天</td>-->
<!--                                    <td>88kal</td>-->
<!--                                </tr>-->
<!--                                <tr>-->
<!--                                    <td>俯卧撑</td>-->
<!--                                    <td>10min</td>-->
<!--                                    <td>每三天</td>-->
<!--                                    <td>100kal</td>-->
<!--                                </tr>-->
<!--                                <tr>-->
<!--                                    <td>平板支撑</td>-->
<!--                                    <td>3min</td>-->
<!--                                    <td>每周</td>-->
<!--                                    <td>123kal</td>-->
<!--                                </tr>-->
                            </tbody>
                        </table>
                    </div>
                    <div class="item">
                        <div class="table-title">
                            <span>干预时间</span>
                            <span>干预形式</span>
                            <span>主要内容</span>
                        </div>
                        <table class="table" border="0" cellspacing="0" cellpadding="0">
                            <tbody id="pla1">
<!--                                <tr>-->
<!--                                    <td>三餐</td>-->
<!--                                    <td>营养饮食</td>-->
<!--                                    <td>减少食盐</td>-->
<!--                                </tr>-->
<!--                                <tr>-->
<!--                                    <td>三餐</td>-->
<!--                                    <td>营养饮食</td>-->
<!--                                    <td>增加钙摄入</td>-->
<!--                                </tr>-->
<!--                                <tr>-->
<!--                                    <td>每天</td>-->
<!--                                    <td>运动指导</td>-->
<!--                                    <td>有氧代谢运动</td>-->
<!--                                </tr>-->
<!--                                <tr>-->
<!--                                    <td>早晚</td>-->
<!--                                    <td>中医养生</td>-->
<!--                                    <td>按摩足部穴位</td>-->
<!--                                </tr>-->
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- 页面 css js -->

    <script src="plugins/jquery/dist/jquery.min.js"></script>
    <script src="js/page-health-intervention.js"></script>
    <script>


        $.ajax({
            url:"diet/byLevel",
            headers:{
                //Bearer token的规范是：Authorization名称的头，值为Bearer空格+具体的jwt串
                "Authorization":"Bearer " + localStorage.getItem("token")
            },
            type:"get",
            "success" :function (data) {
                // console.log(data.data)
                var diets = data.data;
                var str = "";
                for (let i = 0; i < diets.length; i++) {
                    str += "<tr>" +
                        "<td>" + (i + 1) + "</td>" +
                        "<td>" + diets[i].food + "</td>" +
                        "<td>" + diets[i].serving + "</td>" +
                        "<td>" + diets[i].level + "</td>" +
                        "</tr>"
                }
                diet1.innerHTML = str;
            }
            });



        // $.get("/diet/byLevel?level=100",function (data){
        //    // console.log(data.data)
        //     var diets = data.data;
        //     var str ="";
        //     for (let i = 0; i < diets.length; i++) {
        //         str += "<tr>" +
        //         "<td>" + (i + 1) + "</td>" +
        //         "<td>" + diets[i].food + "</td>"+
        //         "<td>" + diets[i].serving + "</td>"+
        //         "<td>" + diets[i].level + "</td>"+
        //         "</tr>"
        //     }
        //     diet1.innerHTML =str;
        //
        // },"json");


        function c3(){
            window.location = "health-index.html"
        }


        function c2(){

            $.ajax({
                url:"plan",
                headers:{
                    //Bearer token的规范是：Authorization名称的头，值为Bearer空格+具体的jwt串
                    "Authorization":"Bearer " + localStorage.getItem("token")
                },
                type:"get",
                "success" :function (data) {
                    var plans = data.data;
                    var str ="";
                    for (let i = 0; i < plans.length; i++) {
                        str += "<tr>" +
                            "<td>" + plans[i].time + "</td>" +
                            "<td>" + plans[i].style+ "</td>"+
                            "<td>" + plans[i].content + "</td>"+
                            "</tr>"
                    }
                    pla1.innerHTML =str;
                }
            });



            // $.get("/plan?level=100",function (data){
            //     // console.log(data.data)
            //     var plans = data.data;
            //     var str ="";
            //     for (let i = 0; i < plans.length; i++) {
            //         str += "<tr>" +
            //             "<td>" + plans[i].time + "</td>" +
            //             "<td>" + plans[i].style+ "</td>"+
            //             "<td>" + plans[i].content + "</td>"+
            //             "</tr>"
            //     }
            //     pla1.innerHTML =str;
            //
            // },"json");
        }

        function c1(){

            $.ajax({
                url:"sport",
                headers:{
                    //Bearer token的规范是：Authorization名称的头，值为Bearer空格+具体的jwt串
                    "Authorization":"Bearer " + localStorage.getItem("token")
                },
                type:"get",
                "success" :function (data) {
                    var sports = data.data;
                    var str ="";
                    for (let i = 0; i < sports.length; i++) {
                        str += "<tr>" +
                            "<td>" + sports[i].name + "</td>" +
                            "<td>" + sports[i].duration+ "</td>"+
                            "<td>" + sports[i].cycle + "</td>"+
                            "<td>" + sports[i].consume + "</td>"+
                            "</tr>"
                    }
                    sport.innerHTML =str;
                }
            });




            // $.get("/sport?level=100",function (data){
            //     // console.log(data.data)
            //     var sports = data.data;
            //     var str ="";
            //     for (let i = 0; i < sports.length; i++) {
            //         str += "<tr>" +
            //             "<td>" + sports[i].name + "</td>" +
            //             "<td>" + sports[i].duration+ "</td>"+
            //             "<td>" + sports[i].cycle + "</td>"+
            //             "<td>" + sports[i].consume + "</td>"+
            //             "</tr>"
            //     }
            //     sport.innerHTML =str;
            //
            // },"json");
        }

       // new Vue({
       //     el: "app",
       //     methods: {
       //         // axios ({
       //         //     url: "/diet/findAll",
       //         //
       //         //       })
       //     }
       // })
    </script>
</body>